<?php
class TTT_Myfilter_Block_Adminhtml_Myfilter_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
	public function __construct()
    {
        parent::__construct();
        $this->setId('myfilterGrid');
        $this->setDefaultSort('filter_id');
        $this->setDefaultDir('ASC');
        $this->setSaveParametersInSession(true);
    }

	protected function _prepareCollection()
    {
        $collection = Mage::getModel('myfilter/myfilter')->getCollection();
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

    protected function _prepareColumns()
    {
        $this->addColumn('filter_id', array(
          'header'    => Mage::helper('myfilter')->__('ID'),
          'align'     =>'right',
          'width'     => '5px',
          'index'     => 'filter_id',
        ));

        $this->addColumn('name', array(
          'header'    => Mage::helper('myfilter')->__('Name'),
          'width'     => '500px',
          'index'     => 'name',
        ));

        $this->addColumn('entity', array(
          'header'    => Mage::helper('myfilter')->__('Entity'),
          'index'     => 'entity',
          'type'      => 'options',
          'options'   => Mage::getModel('myfilter/entity')->getOptionArray()
        ));

        $this->addColumn('menu', array(
          'header'    => Mage::helper('myfilter')->__('Added to Menu'),
          'index'     => 'menu',
          'type'      => 'options',
          'options'   => Mage::getModel('myfilter/menu')->getOptionArray()

        ));

    }

 	protected function _prepareMassaction()
    {
        $this->setMassactionIdField('filter_id');
        $this->getMassactionBlock()->setFormFieldName('filter');

        $this->getMassactionBlock()->addItem('delete', array(
             'label'    => Mage::helper('myfilter')->__('Delete Filter'),
             'url'      => $this->getUrl('*/*/massDelete'),
             'confirm'  => Mage::helper('myfilter')->__('Are you sure?')
        ));

        $statuses = Mage::getModel('myfilter/menu')->getOptionArray();

        array_unshift($statuses, array('label'=>'', 'value'=>''));
        $this->getMassactionBlock()->addItem('status', array(
             'label'=> Mage::helper('myfilter')->__('Change Menu Status'),
             'url'  => $this->getUrl('*/*/massStatus', array('_current'=>true)),
             'additional' => array(
                    'visibility' => array(
                         'name' => 'status',
                         'type' => 'select',
                         'class' => 'required-entry',
                         'label' => Mage::helper('myfilter')->__('Menu Status'),
                         'values' => $statuses
                     )
             )
        ));
        return $this;
    }


}